Bestsoft ID:
Password:  


C

Start writting your Operating System now in C by Downloading Bestsoft Space IDE Download

Display largest number and its location Example
main.c


#include "bestsoft.h"
#define MAXSIZE 10
int main
(struct multiboot *mboot_ptr)
{
       clear
();
        int array[100], maximum, size, c, location = 1;
        
        write
("Enter the count of elements \n");
         
        size=5;
        
        write
("Enter the elements one by one \n");

      
        array[0]=1;
        array[1]=23;
        array[2]=18;
        array[3]=16;
       array[4]=24;
        maximum = array[0];
        
        for (c = 1; c < size; c++)
        {
                if 
(array[c] > maximum)
                {
                        maximum  = array[c];
                        location = c+1;
                }
        }
        write_dec
(location);
        write
("\n");
        write_dec
(maximum);
        return 0;
}

void  write_dec
(u32int n)
{
    if (n == 0)
    {
        monitor_put
('0');
        return;
    }

    s32int acc = n;
    Char c[32];
    int i = 0;
    while 
(acc > 0)
    {
        c[i] = '0' + acc%10;
        acc /= 10;
        i++;
    }
    c[i] = 0;

    Char c2[32];
    c2[i--] = 0;
    int j = 0;
    while(i >= 0)
    {
        c2[i--] = c[j++];
    }
    write
(c2);
}